package com.liuboya.dao.weibo.wbuser.dao;

import com.google.common.base.Preconditions;
import com.liuboya.dao.weibo.wbuser.entity.WbUser;
import com.liuboya.dao.weibo.wbuser.entity.WbUserExample;
import com.liuboya.dao.weibo.wbuser.mapper.WbUserMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 描述：
 *
 * @author yeyuan
 * @date 2021/08/27 16:14
 **/
@Service
public class WbUserDaoImpl implements WbUserDao {
    @Resource
    private WbUserMapper wbuserMapper;

    @Override
    public Long insert(WbUser wbuser) {
        Preconditions.checkNotNull(wbuser);
        wbuser.checkBeforeInsert();
        wbuserMapper.insertSelective(wbuser);
        return wbuser.getId();
    }

    @Override
    public Integer update(WbUser wbuser, WbUserExample example) {
        wbuser.checkBeforeUpdate();
        return wbuserMapper.updateByExampleSelective(wbuser, example);
    }

    @Override
    public List<WbUser> find(WbUserExample example) {
        return wbuserMapper.selectByExample(example);
    }

    @Override
    public Integer count(WbUserExample example) {
        return wbuserMapper.countByExample(example);
    }
}